<?php

namespace App\Admin\Controllers;

use App\Models\ExhibitorInformation;
use App\Models\ExhibitorMessage;
use App\Models\MessageProcessCount;
use App\Models\SafetyAgreement;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class MessageProcessCountController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = 'MessageProcessCount';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new MessageProcessCount());

        $grid->column('safety_agreement_id', __('Safety agreement id'));
        $grid->column('journal_content_id', __('Journal content id'));
        $grid->column('certificates_exhibitor_information_id', __('Certificates exhibitor information id'));
        $grid->column('exhibitor_message_id', __('Exhibitor message id'));
        $grid->column('certificates_exhibitor_information_number', __('Certificates exhibitor information number'));

        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(MessageProcessCount::findOrFail($id));

        $show->field('id', __('Id'));
        $show->field('safety_agreement_id', __('Safety agreement id'));
        $show->field('journal_content_id', __('Journal content id'));
        $show->field('certificates_exhibitor_information_id', __('Certificates exhibitor information id'));
        $show->field('exhibitor_message_id', __('Exhibitor message id'));
        $show->field('certificates_exhibitor_information_number', __('Certificates exhibitor information number'));

        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new MessageProcessCount());
        $exhibitor_information=ExhibitorInformation::query()->where('status', 1)->pluck('name', 'id')->toArray();
        $form->select('certificates_exhibitor_information_id', __('message_process_count.certificates_exhibitor_information_id'))
            ->options($exhibitor_information)->rules(['required']);
        $form->number('certificates_exhibitor_information_number', __('message_process_count.certificates_exhibitor_information_number'));

        $exhibitor_message = ExhibitorMessage::query()->where('status', 1)->pluck('title', 'id')->toArray();
        $form->select('exhibitor_message_id', __('message_process_count.exhibitor_message_id'))
            ->options($exhibitor_message);
        $safety_agreement=SafetyAgreement::query()->pluck('file_name', 'id')->toArray();
        $form->select('safety_agreement_id', __('message_process_count.safety_agreement_id'))
            ->options($safety_agreement);
        $form->number('journal_content_id', __('message_process_count.journal_content_id'));



        return $form;
    }
}
